//
//  XDClassSynchronizationController.m
//  XDEducation
//
//  Created by Ethan on 2017/5/15.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDClassSynchronizationController.h"
#import "XDSelectCourseData.h"
#import "XDConstantHeaderFile.h"
@interface XDClassSynchronizationController ()
/** 页面数据 */
@property(nonatomic,strong) NSMutableArray *dataSource;
@property (nonatomic,strong) NSMutableArray *dataArray;
@property (nonatomic,strong) UIButton *oneButton;
@property (nonatomic,strong) UIButton *towButton;
@property (nonatomic,strong) UIButton *threeButton;
@property (nonatomic,strong) UIButton *fourButton;
@property (nonatomic,strong) UIButton *fiveButton;
@property (nonatomic,strong) UIButton *sixButton;
@property (nonatomic,strong) UIButton *butotn;
@property (nonatomic,strong) UIButton *nextButton;



@end

@implementation XDClassSynchronizationController

- (NSMutableArray *)dataArray {
    if (_dataArray == nil) {
        self.dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (NSMutableArray *)dataSource {
    
    if (_dataSource == nil) {
        self.dataSource = [NSMutableArray arrayWithObjects:@"语文",@"数学",@"英文", nil];
    }
    
    return _dataSource;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.nameStr;
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    
    [self setUpSuperViews];
}

- (void)setUpSuperViews{
    CGFloat itemW = 100 * ScaleWidth;
    CGFloat itemH = 35 * ScaleHeight;
    CGFloat padding = (ScreenW - 3 * itemW)/4;
    CGFloat paddingY = 20;
    CGFloat itemX = padding;
    CGFloat itemY = paddingY;
    
    UILabel *oneLabel = [[UILabel alloc]initWithFrame:CGRectMake(itemX, itemY, itemW, itemH)];
//    oneLabel.backgroundColor = [UIColor redColor];
    oneLabel.text = @"选择科目";
    oneLabel.textAlignment = NSTextAlignmentLeft;
    oneLabel.font = [UIFont systemFontOfSize:10];
    oneLabel.textColor = [UIColor blackColor];
    [self.view addSubview:oneLabel];
    
    
        int tempI = 0;
        int tempJ = 0;
        for (int i = 0; i < self.dataSource.count; i ++) {
    
            NSString *itemName = self.dataSource[i];
    
    
            BOOL isMultipleOfFour = !(i % 3);
    
            if (isMultipleOfFour && i != 0) {
                tempJ ++;
                tempI = 0;
                itemY = paddingY + (itemH + paddingY) * tempJ;
            }
    
    
            UIButton *button = [[UIButton alloc]init];
            button.frame =  CGRectMake(itemX + tempI * (padding + itemW),oneLabel.frame.origin.y +oneLabel.frame.size.height + kScreenHeight *40/1334 , itemW, itemH);
    
    
            [button setTitle:itemName forState:UIControlStateNormal];
    
            [button setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
            [button setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
            [button setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    
            //button.titleLabel.font = iPhone5?[UIFont systemFontOfSize:10]:[UIFont systemFontOfSize:12];
            button.titleLabel.font = [UIFont systemFontOfSize:14];
            button.titleLabel.textAlignment = NSTextAlignmentCenter;
            self.butotn = button;
            [self.view addSubview:button];
    
            tempI ++;
    
            button.tag = i;
    
            
            [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
        }

    
    UILabel *lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.butotn.frame.origin.y + self.butotn.frame.size.width /2 + kScreenHeight * 40/1334, kScreenWidth, 0.5)];
    lineLabel.backgroundColor = [UIColor blackColor];
    [self.view addSubview:lineLabel];
    
    
    
    
    
    UILabel *towLabel = [[UILabel alloc]initWithFrame:CGRectMake(oneLabel.frame.origin.x, lineLabel.frame.origin.y + lineLabel.frame.size.height + kScreenHeight *40/1334, self.butotn.frame.size.width, self.butotn.frame.size.height)];
//    towLabel.backgroundColor = [UIColor redColor];
    towLabel.text = @"选择年级";
    towLabel.textColor = [UIColor blackColor];
    towLabel.font = [UIFont systemFontOfSize:10];
    towLabel.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:towLabel];
    
    //1
    self.oneButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.oneButton.frame = CGRectMake(towLabel.frame.origin.x, towLabel.frame.origin.y + towLabel.frame.size.height + kScreenHeight *40/1334, towLabel.frame.size.width, towLabel.frame.size.height);
    
    [self.oneButton setTitle:@"一年级" forState:(UIControlStateNormal)];
    [self.oneButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.oneButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.oneButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.oneButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    
    
    self.oneButton.tag = 201;
    [self.dataArray addObject:self.oneButton];
    [self.oneButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.oneButton];
    
    
    
    //2
    self.towButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.towButton.frame = CGRectMake(self.oneButton.frame.origin.x  + self.oneButton.frame.size.width + kScreenHeight *40/1334 , self.oneButton.frame.origin.y, towLabel.frame.size.width, towLabel.frame.size.height);
    [self.towButton setTitle:@"二年级" forState:(UIControlStateNormal)];
    [self.towButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.towButton.titleLabel.font = [UIFont systemFontOfSize:14];

    [self.towButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.towButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    self.towButton.tag = 202;
    [self.dataArray addObject:self.towButton];
    [self.towButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.towButton];
    
    
    //3
    self.threeButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.threeButton.frame = CGRectMake(self.towButton.frame.origin.x + self.towButton.frame.size.width + kScreenHeight *40/1334, towLabel.frame.origin.y + towLabel.frame.size.height + kScreenHeight *40/1334, towLabel.frame.size.width, towLabel.frame.size.height);
    [self.threeButton setTitle:@"三年级" forState:(UIControlStateNormal)];
    [self.threeButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.threeButton.titleLabel.font = [UIFont systemFontOfSize:14];
    


    [self.threeButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.threeButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    self.threeButton.tag = 203;
    [self.dataArray addObject:self.threeButton];
    [self.threeButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.threeButton];

    //4
    self.fourButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.fourButton.frame = CGRectMake(self.oneButton.frame.origin.x, self.oneButton.frame.origin.y +self.oneButton.frame.size.height + kScreenHeight *40/1334, self.oneButton.frame.size.width, self.oneButton.frame.size.height);
    [self.fourButton setTitle:@"四年级" forState:(UIControlStateNormal)];
    [self.fourButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.fourButton.titleLabel.font = [UIFont systemFontOfSize:14];
    
    

    [self.fourButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.fourButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    self.fourButton.tag = 204;
    [self.dataArray addObject:self.fourButton];
    [self.fourButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.fourButton];
    
    //5
    self.fiveButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.fiveButton.frame = CGRectMake(self.towButton.frame.origin.x,self.fourButton.frame.origin.y,self.fourButton.frame.size.width,self.fourButton.frame.size.height);
    [self.fiveButton setTitle:@"五年级" forState:(UIControlStateNormal)];
    [self.fiveButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.fiveButton.titleLabel.font = [UIFont systemFontOfSize:14];
    

    [self.fiveButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.fiveButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    self.fiveButton.tag = 205;
    [self.dataArray addObject:self.fiveButton];
    [self.fiveButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.fiveButton];

    
    //6
    self.sixButton =[UIButton buttonWithType:(UIButtonTypeCustom)];
    self.sixButton.frame = CGRectMake(self.threeButton.frame.origin.x,self.fiveButton.frame.origin.y,self.fiveButton.frame.size.width,self.fiveButton.frame.size.height);
    [self.sixButton setTitle:@"六年级" forState:(UIControlStateNormal)];
    [self.sixButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.sixButton.titleLabel.font = [UIFont systemFontOfSize:14];
    

    [self.sixButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_default"] forState:UIControlStateNormal];
    [self.sixButton setBackgroundImage:[UIImage imageNamed:@"list_btn_blue_selected"] forState:UIControlStateSelected];
    self.sixButton.tag = 206;
    [self.dataArray addObject:self.sixButton];
    [self.sixButton addTarget:self action:@selector(allSelectAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.sixButton];
    
    UILabel *towLine = [[UILabel alloc]initWithFrame:CGRectMake(0, self.fourButton.frame.origin.y + self.fourButton.frame.size.width/2+ kScreenHeight *40/1334, kScreenWidth,0.5)];
    towLine.backgroundColor = [UIColor blackColor];
    [self.view addSubview:towLine];
    
    
    self.nextButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.nextButton.frame = CGRectMake(oneLabel.frame.origin.x , towLine.frame.origin.y + towLine.frame.size.height + kScreenHeight *40/1334, kScreenWidth - oneLabel.frame.origin.x*2, self.fourButton.frame.size.height) ;
    [self.nextButton setBackgroundImage:[UIImage imageNamed:@"login_btn_login_default"] forState:(UIControlStateNormal)];
    
    [self.view addSubview:self.nextButton];
    
    


    
}

- (void)buttonClicked:(UIButton *)sender {
    
    
}

- (void)allSelectAction:(UIButton *)sender {
    NSInteger tag = sender.tag;
    if (201 == tag) {
        
    }else if (202 == tag){
        
    }else if (203 == tag){
        
    }else if (204 == tag){
        
    }else if (205 == tag){
        
    }else if (206 == tag){
        
    }
    
}


//nothing by halves  凡事不可半途而废





























@end
